home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / Tools / EasyGUI / Plugins / iconify.e < prev    next >
Encoding:
Text File  |  1997-07-07  |  2.8 KB  |  95 lines

  1. OPT MODULE, PREPROCESS
  2.  
  3. MODULE 'intuition/intuition', 'intuition/gadgetclass',
  4.        'libraries/gadtools',
  5.        'tools/textlen',
  6.        'tools/EasyGUI',
  7.        'workbench/startup', 'workbench/workbench',
  8.        'gadtools', 'icon', 'wb'
  9.  
  10. RAISE "icfy" IF AddAppIconA()=NIL,
  11.       "icfy" IF OpenLibrary()=NIL,
  12.       "icfy" IF CreateMsgPort()=NIL
  13.  
  14. DEF iconbase  -> Redefine for privateness
  15.  
  16. -> Share gadtoolbase and workbenchbase with EasyGUI...
  17.  
  18. #define DEFICON 'env:sys/def_tool'
  19.  
  20. EXPORT OBJECT iconify OF plugin
  21.   disabled
  22. PRIVATE
  23.   iconify:PTR TO gadget
  24.   iconopen
  25.   label, icon, iconlabel
  26.   resize
  27. ENDOBJECT
  28.  
  29. PROC iconify(label,icon=NIL,iconlabel=NIL,
  30.              resizex=FALSE,resizey=FALSE,disabled=FALSE) OF iconify
  31.   iconbase:=OpenLibrary('icon.library',37)
  32.   self.iconopen:=TRUE
  33.   self.label:=IF label THEN label ELSE ''
  34.   self.icon:=IF icon THEN icon ELSE DEFICON
  35.   self.iconlabel:=IF iconlabel THEN iconlabel ELSE self.label
  36.   self.disabled:=disabled
  37.   self.resize:=(IF resizex THEN RESIZEX ELSE 0) OR
  38.                (IF resizey THEN RESIZEY ELSE 0)
  39. ENDPROC
  40.  
  41. PROC end() OF iconify
  42.   IF self.iconopen
  43.     CloseLibrary(iconbase)
  44.     self.iconopen:=FALSE
  45.   ENDIF
  46. ENDPROC
  47.  
  48. PROC min_size(ta,fh) OF iconify IS textlen(self.label,ta)+16,fh+6
  49.  
  50. PROC will_resize() OF iconify IS self.resize
  51.  
  52. -> Don't need to define this:
  53. ->PROC render(ta,x,y,xs,ys,w) OF iconify IS EMPTY
  54.  
  55. PROC gtrender(gl,vis,ta,x,y,xs,ys,w) OF iconify
  56.   -> Or, a gadget in the title bar would have also been nice...
  57.   self.iconify:=CreateGadgetA(BUTTON_KIND,gl,
  58.                  [x,y,xs,ys,self.label,ta,0,
  59.                   PLACETEXT_IN,vis,NIL]:newgadget, [NIL])
  60.   IF self.iconify=NIL THEN Raise("icfy")
  61. ENDPROC self.iconify
  62.  
  63. -> Don't need to define this:
  64. -> PROC clear_render(win:PTR TO window) OF iconify IS EMPTY
  65.  
  66. PROC message_test(imsg:PTR TO intuimessage,win:PTR TO window) OF iconify
  67.   IF imsg.class=IDCMP_GADGETUP THEN RETURN imsg.iaddress=self.iconify
  68. ENDPROC FALSE
  69.  
  70. PROC message_action(class,qual,code,win:PTR TO window) OF iconify HANDLE
  71.   DEF dobj=NIL:PTR TO diskobject, myport=NIL, appicon=NIL,
  72.       appmsg:PTR TO appmessage
  73.   closewin(self.gh)
  74.   -> Fallback to using a default icon if not found...
  75.   IF NIL=(dobj:=GetDiskObjectNew(self.icon)) THEN dobj:=GetDiskObjectNew(DEFICON)
  76.   dobj.type:=NIL
  77.   myport:=CreateMsgPort()
  78.   appicon:=AddAppIconA(0,0,self.iconlabel,myport,NIL,dobj,NIL)
  79.   WaitPort(myport)
  80. EXCEPT DO
  81.   IF appicon THEN RemoveAppIcon(appicon)
  82.   IF myport
  83.     -> Clear away any messages that arrived at the last moment
  84.     WHILE appmsg:=GetMsg(myport) DO ReplyMsg(appmsg)
  85.     DeleteMsgPort(myport)
  86.   ENDIF
  87.   IF dobj THEN FreeDiskObject(dobj)
  88.   openwin(self.gh)
  89. ENDPROC FALSE
  90.  
  91. PROC setdisabled(disabled=TRUE) OF iconify
  92.   Gt_SetGadgetAttrsA(self.iconify,self.gh.wnd,NIL,[GA_DISABLED,disabled,NIL])
  93.   self.disabled:=disabled
  94. ENDPROC
  95.